﻿using System;
using System.Diagnostics;
using System.Globalization;
using NUnit.Framework;
using Whois.API.Model;

namespace Tests.ModelTests
{
    public class WhoisTests : SerializationTestBase<WhoisRecord>
    {
        [Test]
        public void Google()
        {
            var result = DeSerialise("google");
            Assert.IsNotNull(result);
            VerifyResult(result);
        }

        [Test]
        public void Microsoft()
        {
            var result = DeSerialise("microsoft");
            Assert.IsNotNull(result);
            VerifyResult(result);
        }

        [Test]
        public void Yahoo()
        {
            var result = DeSerialise("yahoo");
            Assert.IsNotNull(result);
            VerifyResult(result);
        }

        [Test]
        public void Date()
        {
            //Custom time format returned for some domains.
            var result = DeSerialise("UtcDate");
            Assert.IsNotNull(result);
            VerifyResult(result);
        }

        private static void VerifyResult(WhoisRecord record)
        {
            Assert.IsNotNull(record.RegistryData);
            Assert.IsNotNull(record.RegistryData.ExpiresDate);
            Assert.GreaterOrEqual(record.RegistryData.ExpiresDate, new DateTime(2011,01, 01));

            //todo add more assert statements
        }
    }
}
